package com.bite.java_chatroom.service;

import com.bite.java_chatroom.mapper.UserInfoMapper;
import com.bite.java_chatroom.model.UserInfo;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserInfoService {
    @Autowired
    UserInfoMapper userInfoMapper;

    public UserInfo login(String username){
        return userInfoMapper.selectByUserName(username);
    }

    public void register(String username,String password){
        userInfoMapper.insertUserInfo(username,password);
    }

    public UserInfo getUserName(Integer id){
        return userInfoMapper.selectById(id);
    }

    public Integer selectIdByUserName(String username) {
        return userInfoMapper.selectIdByUserName(username);
    }
}
